<script setup>
import { ref } from 'vue'

defineProps({
  pictureList: {
    type: Array,
    default: () => []
  }
})
// 鼠标进入小图
const index = ref(0)
const mouseEnterFn = (i) => (index.value = i)
</script>

<template>
  <div class="goods-image">
    <!-- 左侧大图-->
    <div class="middle">
      <img :src="pictureList[index]" ref="target" alt="" />
    </div>
    <!-- 小图列表 -->
    <ul class="small">
      <li
        v-for="(img, i) in pictureList"
        :key="i"
        :class="{ active: i === index }"
      >
        <img :src="img" alt="" @mouseenter="mouseEnterFn(i)" />
      </li>
    </ul>
    <!-- 放大镜大图 -->
    <!-- <div
      class="large"
      :style="[
        {
          backgroundImage: `url(${pictureList[index]})`,
          backgroundPositionX: `${positionX}px`,
          backgroundPositionY: `${positionY}px`
        }
      ]"
      v-show="!isOutside"
    ></div> -->
  </div>
</template>

<style scoped lang="scss">
img {
  object-fit: cover;
}
.goods-image {
  width: 520px;
  height: 520px;
  position: relative;

  .middle {
    width: 100%;
    height: 420px;
    background: #f5f5f5;
    // border: 2px solid blue;

    img {
      width: 100%;
      height: 100%;
    }
  }

  .small {
    // width: 80px;
    height: 90px;
    display: flex;

    li {
      width: 100px;
      margin: 10px 5px 0 0;

      // height: 68px;
      // margin-left: 12px;
      // margin-bottom: 15px;
      cursor: pointer;

      &:last-child {
        margin-right: 0;
      }

      &:hover,
      &.active {
        border: 2px solid $xtxColor;
      }
    }
  }
}
</style>
